<?php 
if($_GET['act']=='delete'&&$_POST['submit']!=''){
    for($i=0;$i<count($_POST['selectbox']);$i++)
    {
        $query = "delete from ".DBPREFIX."exam where exam_id=".$_POST['selectbox'][$i];
        $result = $db->query($query);
    }
    if($result){
        fs_showmsg('删除成功!','?do=elist');
    }
    else{
        fs_showmsg('删除失败!');
    }
}
?>
<form action="?do=elist&&act=delete" method="post" onsubmit="return checkBoxSelect()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr><td>
    <div class="submenu_t">
            <ul>
                <?php
                    $query = "select * from ".DBPREFIX."exam_thread where exam_id=".$_GET['id'];
                    $result = $db->query($query);
                    while($row = $db->fetch_array($result)){
                ?>
                <li><a href="?do=showexam&id=<?php echo $_GET['id']?>&tid=<?php echo $row['thread_id']?>"><?php switch($row['thread_type']){ case 1:echo '单项选择题';break;case 2:echo '多项选择题';break;default:echo '判断题';break;}?></a></li>
                <?php
                    }
                ?>
            </ul>
    </div>
    </td>
    </tr>
    <tr><td>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="question_list" id="tblist">
                            <thead>
                                    <tr>
                                            <th></th>
                                        <th>考题编号</th>
                                        <th>问题标题</th>
                                        <th>问题排序号</th>
                                </tr>
                            </thead>
                            <tbody>
                                    
                                            <?php
                                            if($_GET['tid']=="")
                                            {
                                                $query = "select * from ".DBPREFIX."exam_thread where exam_id=".$_GET['id'];
                                                $result = $db->query($query);
                                                while($q_row = $db->fetch_array($result))
                                                {
                                                    $q_query = "select a.*,b.* from ".DBPREFIX."examconnect as a inner join ".DBPREFIX."question as b on a.q_id=b.q_id where a.thread_id=".$q_row['thread_id'];
                                                    $q_result = $db->query($q_query);
                                                    while($qp_row = $db->fetch_array($q_result))
                                                    {
                                            ?>
                                            <tr>
                                                    <td><input type="checkbox" name="selectbox[]" value="<?php echo $qp_row['exam_id']?>" /></td>
                                                    <td><?php echo $qp_row['q_id']?></td>  
                                                    <td><?php echo $qp_row['q_title']?></td> 
                                                    <td><input type="text" name="qsort"/></td>
                                            </tr>
                                            <?php
                                                    }
                                                 }
                                            }
                                            else{
                                                $r_query = "select a.*,b.* from ".DBPREFIX."examconnect as a inner join ".DBPREFIX."question as b on a.q_id=b.q_id where a.thread_id=".$_GET['tid'];
                                                $r_result = $db->query($r_query);
                                                while($r_row = $db->fetch_array($r_result))
                                                {
                                            ?>
                                             <tr>
                                                    <td><input type="checkbox" name="selectbox[]" value="<?php echo $r_row['exam_id']?>" /></td>
                                                    <td><?php echo $r_row['q_id']?></td>  
                                                    <td><?php echo $r_row['q_title']?></td> 
                                                    <td><input type="text" name="qsort"/></td>
                                            </tr>
                                            <?php       
                                                }
                                            }
                                            ?>
                                            
                                    
                            </tbody>
                    </table>
            </td></tr>
    <tr><td>
    <div class="submenu_b">
            <ul>
                <li><input type="button" name="selectall" id="allselect" value="全选"/></li>
		<li><input type="button" name="noneselect" id="noneselect" value="全不选"/></li>
        <li><input type="button" name="nonesselect" id="elseselect" value="反选"/></li>
		<li><input type="submit" name="submit"   value="删除"/></li>
            </ul>
    </div>
    </td>
    </tr>
</table>
</form>